package PackageVoiture;

public class Voiture
{
    private int kilometrage;
    private int reservoir=30;
    private int plein=30;
    private boolean enPanne=false;
    private Proprietaire proprio=null;
    
    public void setProprio(Proprietaire p){ proprio=p;}
    public void setKilometrage(int klm)
    {  kilometrage=klm;}
    
    public String getProprio(){
    	return this.proprio.getNom();
    }
    
    public int getKilometrage()
    { return kilometrage;}
   
    public void setEssence(int essence)
    {  this.reservoir=essence;}
    
     public int  getEssence()
    { return reservoir;}

 
   //methode manipulant les deux parametres
    public String rouler(int nbKLM)
    {
    	if(! enPanne)
    	{
	        if(nbKLM>=0)
	            if(reservoir>=nbKLM)
	            {
	                kilometrage+=nbKLM;
	                reservoir-=nbKLM; 
	                return "bon";
	            }
	            else  
            	{
            		System.out.println("Essence non suffisant");
            		return "nonSuffisant";
            	}
    	}
    	return "enPanne";
    }
    //methodes annexes
     public boolean Remplir(int nbLitre)
    {
        if(reservoir+nbLitre<=plein)
        {
        	reservoir+=nbLitre;
        	return true;
        }
        System.out.println("Attention Débordement");
        return false;
    }
     public void changerDeProprio(Proprietaire p)
     {
    	setProprio(p); 
     }
     
     public void tomberEnPanne()
     {
    	 enPanne=true;
     }
     
     public void reparer(){enPanne=false;}
}
